Async function execution internals#1355
Conversation
|
PTAL, thanks for the detailed review. I also added a NaN case to the async function call equality check. |
| go func() { | ||
| if semaphore != nil { | ||
| // Release the concurrency slot when this call finishes or is cancelled. | ||
| defer func() { <-semaphore }() |
There was a problem hiding this comment.
Do we need to also release the semaphore right before sending to the completion channel? defer runs at the very end of the goroutine right? If the semaphore is at capacity, there might be a small window where the next async call is rejected because defer hasn't ran.
There was a problem hiding this comment.
I don't think we do. The completions signal indicates when a result is ready for re-evaluation (this will be more obvious in later PRs). The idea is that a batch of results are being accumulated and some logic is trying to decide whether to wait for all pending completions, a certain number of results, or a certain amount of time. The semaphore release at the end is the right thing to do since it should block until the decision about whether re-evaluate is made.
|
PTAL and let me know what you think regarding the last open comment about the semaphore |
Internal support for async function evaluation.
context.Contextobject and expected to blockuntil a result is available and return it. The framework manages go routines
The implementation supports minimal call deduplication logic which users
will be able to extend with functionality introduced into later PRs.